﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Zwms.Client.CommonUI;
using grproLib;

namespace Zwms.Client.Report
{
    public partial class ReportPrintForm : BaseForm
    {
        GridppReport Report = new GridppReport();
        Dictionary<string, string> _dict = null;
        List<Dictionary<string, string>> _dictList = null;
        public ReportPrintForm(string sReportName, List<Dictionary<string, string>> dictList)
        {
            InitializeComponent();
            _dictList = dictList;
            Report.LoadFromFile(Application.StartupPath + string.Format(@"\Reports\{0}", sReportName));
            Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(Report_FetchRecord);

            this.axGRPrintViewer1.Report = Report;
            this.axGRPrintViewer1.Start();
        }

        public ReportPrintForm(string sReportName, Dictionary<string, string> dict)
        {
            InitializeComponent();
            _dict = dict;
            Report.LoadFromFile(Application.StartupPath + string.Format(@"\Reports\{0}", sReportName));
            Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(Report_FetchRecord);

            this.axGRPrintViewer1.Report = Report;
            this.axGRPrintViewer1.Start();
        }

        void Report_FetchRecord()
        {
            if (_dict != null)
            {
                ReportHelper.FillRecordToReport(Report, _dict);
            }
            else
            {
                ReportHelper.FillRecordToReport(Report, _dictList);
            }
        }
    }
}
